package com.tusuo.stds.rest;


import android.content.SharedPreferences;

import com.tusuo.stds.Constants;

import java.util.Map;

import okhttp3.RequestBody;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * @author J.Huang
 * @version 1.0
 *
 */

public class ApiHelper {

    private static final String APP_OS = "Android";

    private Api mApi;
    private SharedPreferences mSharedPref;
    private String mDeviceId;
    private int mVersion;

    public ApiHelper(Api api, SharedPreferences sharedPref, String deviceId, int version) {
        mApi = api;
        mSharedPref = sharedPref;
        mDeviceId = deviceId;
        mVersion = version;
    }

    public void getAppInfo(Subscriber<AppInfo> subscriber) {
        mApi.getAppInfo(mSharedPref.getString(Constants.KEY_COOKIE, ""), APP_OS, mDeviceId, mVersion)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getCaptcha(Subscriber<ApiResult> subscriber, String mobileNo) {
        mApi.getCaptcha(mSharedPref.getString(Constants.KEY_COOKIE, ""), mobileNo)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void register(Subscriber<ApiResult> subscriber, String mobileNo, String password, String captcha) {
        mApi.register(mSharedPref.getString(Constants.KEY_COOKIE, ""), APP_OS, mDeviceId, mobileNo, password, captcha)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void login(Subscriber<ApiResult> subscriber, String mobileNo, String password) {
        mApi.login(mSharedPref.getString(Constants.KEY_COOKIE, ""), APP_OS, mDeviceId, mobileNo, password)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void thirdLogin(Subscriber<ApiResult> subscriber, String openId, String platForm, String accessToken, String nickName, String avatar) {
        mApi.thirdLogin(mSharedPref.getString(Constants.KEY_COOKIE, ""), APP_OS, mDeviceId, openId, platForm, accessToken, nickName, avatar)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void linkAccount(Subscriber<ApiResult> subscriber, String mobileNo, String password, String openId, String platForm, String accessToken, String nickName, String avatar) {
        mApi.linkAccount(mSharedPref.getString(Constants.KEY_COOKIE, ""), APP_OS, mDeviceId, mobileNo, password, openId, platForm, accessToken, nickName, avatar)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void bindNew(Subscriber<ApiResult> subscriber, String mobileNo, String password, String captcha, String openId, String platForm, String accessToken, String nickName, String avatar) {
        mApi.bindNew(mSharedPref.getString(Constants.KEY_COOKIE, ""), APP_OS, mDeviceId, mobileNo, password, captcha, openId, platForm, accessToken, nickName, avatar)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void bindCurrent(Subscriber<ApiResult> subscriber, String openId, String platForm, String accessToken, String nickName, String avatar) {
        mApi.bindCurrent(mSharedPref.getString(Constants.KEY_COOKIE, ""), openId, platForm, accessToken, nickName, avatar)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void unbindThird(Subscriber<ApiResult> subscriber, String platForm) {
        mApi.unbindThird(mSharedPref.getString(Constants.KEY_COOKIE, ""), platForm)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void logout(Subscriber<ApiResult> subscriber) {
        mApi.logout(mSharedPref.getString(Constants.KEY_COOKIE, ""), APP_OS, mDeviceId)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void setPassword(Subscriber<ApiResult> subscriber, String mobileNo, String password, String captcha) {
        mApi.setPassword(mSharedPref.getString(Constants.KEY_COOKIE, ""), mobileNo, password, captcha)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void modifyPassword(Subscriber<ApiResult> subscriber, String oldPassword, String newPassword) {
        mApi.modifyPassword(mSharedPref.getString(Constants.KEY_COOKIE, ""), oldPassword, newPassword)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getUserInfo(Subscriber<UserInfo> subscriber) {
        mApi.getUserInfo(mSharedPref.getString(Constants.KEY_COOKIE, ""))
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void uploadImg(Subscriber<UploadResponse> subscriber, String description, Map<String, RequestBody> maps , String typeKey) {
        mApi.uploadImg(mSharedPref.getString(Constants.KEY_COOKIE, ""), typeKey , description, maps)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void setAvatar(Subscriber<ApiResult> subscriber, String url) {
        mApi.setAvatar(mSharedPref.getString(Constants.KEY_COOKIE, ""), url)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void setName(Subscriber<ApiResult> subscriber, String name) {
        mApi.setName(mSharedPref.getString(Constants.KEY_COOKIE, ""), name)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void setGender(Subscriber<ApiResult> subscriber, int gender) {
        mApi.setGender(mSharedPref.getString(Constants.KEY_COOKIE, ""), gender)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void setMobileNum(Subscriber<ApiResult> subscriber,
                             String mobileNum,
                             String password,
                             String verifyCode) {
        mApi.setMobileNum(mSharedPref.getString(Constants.KEY_COOKIE, ""), mobileNum, password, verifyCode)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getArea(Subscriber<AreaList> subscriber) {
        mApi.getArea(mSharedPref.getString(Constants.KEY_COOKIE, ""))
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getSchool(Subscriber<SchoolList> subscriber, int areaId) {
        mApi.getSchool(mSharedPref.getString(Constants.KEY_COOKIE, ""), areaId)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void setSchool(Subscriber<ApiResult> subscriber,
                          int schoolId, String schoolName) {
//                          int provinceId, String provinceName,
//                          int cityId, String cityName,
//                          int areaId, String areaName) {
        mApi.setSchool(mSharedPref.getString(Constants.KEY_COOKIE, ""),
                schoolId, schoolName)
//                provinceId, provinceName,
//                cityId, cityName,
//                areaId, areaName)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getSceneList(Subscriber<SceneList> subscriber) {
        mApi.getSceneList(mSharedPref.getString(Constants.KEY_COOKIE, ""))
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getSceneList(Subscriber<SceneList> subscriber,int type,String keyword) {
        mApi.getSceneList(mSharedPref.getString(Constants.KEY_COOKIE, ""),type,keyword)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }


    public void getSceneDetail(Subscriber<SceneDetail> subscriber,int sceneId) {
        mApi.getSceneDetail(mSharedPref.getString(Constants.KEY_COOKIE, ""),sceneId)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);

    }

    public void getBankList(Subscriber<QuestionBankList> subscriber) {
        mApi.getBankList(mSharedPref.getString(Constants.KEY_COOKIE, ""))
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getLevelRecordList(Subscriber<LevelRecordList> subscriber, int pageNo, int pageSize) {
        mApi.getLevelRecordList(mSharedPref.getString(Constants.KEY_COOKIE, ""), pageNo, pageSize)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getLevelRecordDetail(Subscriber<LevelRecordDetail> subscriber, int levelRecordId) {
        mApi.getLevelRecordDetail(mSharedPref.getString(Constants.KEY_COOKIE, ""), levelRecordId)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getModuleList(Subscriber<ModuleList> subscriber, int sceneId) {
        mApi.getModuleList(mSharedPref.getString(Constants.KEY_COOKIE, ""), sceneId)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getLevelList(Subscriber<LevelList> subscriber, int moduleId) {
        mApi.getLevelList(mSharedPref.getString(Constants.KEY_COOKIE, ""), moduleId)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getLevelDetail(Subscriber<LevelDetail> subscriber, int levelId) {
        mApi.getLevelDetail(mSharedPref.getString(Constants.KEY_COOKIE, ""), levelId)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void submitAnswer(Subscriber<ApiResult> subscriber,
                             int levelRecordId,
                             int recordQuestionId,
                             long clearanceTime,
                             String answerContent) {
        mApi.submitAnswer(mSharedPref.getString(Constants.KEY_COOKIE, ""), levelRecordId, recordQuestionId, clearanceTime, answerContent)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getLevelResult(Subscriber<LevelResult> subscriber, int levelResultId) {
        mApi.getLevelResult(mSharedPref.getString(Constants.KEY_COOKIE, ""), levelResultId)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getSceneRank(Subscriber<RankList> subscriber, int sceneId) {
        mApi.getSceneRank(mSharedPref.getString(Constants.KEY_COOKIE, ""), sceneId)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getModuleRank(Subscriber<RankList> subscriber, int moduleId) {
        mApi.getModuleRank(mSharedPref.getString(Constants.KEY_COOKIE, ""), moduleId)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getQuestionBankContent(Subscriber<QuestionBankContent> subscriber, String ids) {
        mApi.getQuestionBankContent(mSharedPref.getString(Constants.KEY_COOKIE, ""), ids)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getQuestionBankGroup(Subscriber<QuestionBankGroup> subscriber) {
        mApi.getQuestionBankGroup(mSharedPref.getString(Constants.KEY_COOKIE, ""))
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void removeWrongQuestion(Subscriber<ApiResult> subscriber, int wrongQuestionId) {
        mApi.removeWrongQuestion(mSharedPref.getString(Constants.KEY_COOKIE, ""), wrongQuestionId)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getWrongQuestionSetting(Subscriber<WrongQuestionSetting> subscriber) {
        mApi.getWrongQuestionSetting(mSharedPref.getString(Constants.KEY_COOKIE, ""))
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void setWrongQuestionSetting(Subscriber<ApiResult> subscriber, int correctCount) {
        mApi.setWrongQuestionSetting(mSharedPref.getString(Constants.KEY_COOKIE, ""), correctCount)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void submitWrongQuestionAnswer(Subscriber<WrongQuestionAnswerResult> subscriber,
                                          int wrongQuestionId,
                                          String answerContent) {
        mApi.submitWrongQuestionAnswer(mSharedPref.getString(Constants.KEY_COOKIE, ""), wrongQuestionId, answerContent)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void setOpenSimilarity(Subscriber<ApiResult> subscriber,
                                          boolean isOpening) {
        mApi.setOpenSimilarity(mSharedPref.getString(Constants.KEY_COOKIE, ""), isOpening)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getSimilarityDetail(Subscriber<SimilarityDetail> subscriber) {
        mApi.getSimilarityDetail(mSharedPref.getString(Constants.KEY_COOKIE, ""))
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void submitSimilarityAnswer(Subscriber<ApiResult> subscriber,
                             int recordQuestionId,
                             long clearanceTime,
                             String answerContent) {
        mApi.submitSimilarityAnswer(mSharedPref.getString(Constants.KEY_COOKIE, ""), recordQuestionId, clearanceTime, answerContent)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getSimilarityInfo(Subscriber<SimilarityInfo> subscriber) {
        mApi.getSimilarityInfo(mSharedPref.getString(Constants.KEY_COOKIE, ""))
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getSceneUnlockAttachData(Subscriber<AttachDataResult> subscriber, int sceneId) {
        mApi.getSceneUnlockAttachData(mSharedPref.getString(Constants.KEY_COOKIE,""),sceneId)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getSceneRewardAttachData(Subscriber<AttachDataResult> subscriber, int sceneId ,int money) {
        mApi.getSceneRewardAttachData(mSharedPref.getString(Constants.KEY_COOKIE,""),sceneId,money)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getPayParam(Subscriber<PayParam> subscriber,String payMethod,String attachData) {
        mApi.getPayParam(mSharedPref.getString(Constants.KEY_COOKIE,""),payMethod,attachData)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getTenPayParam(Subscriber<TenPayParam> subscriber,String payMethod,String attachData) {
        mApi.getTenPayParam(mSharedPref.getString(Constants.KEY_COOKIE,""),payMethod,attachData)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getQQPayParam(Subscriber<QQPayParam> subscriber,String payMethod,String attachData) {
        mApi.getQQPayParam(mSharedPref.getString(Constants.KEY_COOKIE,""),payMethod,attachData)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getVipList(Subscriber<VipList> subscriber) {
        mApi.getVipList(mSharedPref.getString(Constants.KEY_COOKIE,""))
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getVipAttachData(Subscriber<AttachDataResult> subscriber,int id) {
        mApi.getVipAttachData(mSharedPref.getString(Constants.KEY_COOKIE,""),id)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getComplete(Subscriber<Complete> subscriber,int dataId,int type) {
        mApi.getComplete(mSharedPref.getString(Constants.KEY_COOKIE,""),dataId,type)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getCompleteDetail(Subscriber<CompleteDetail> subscriber,int dataId,int type,int completeId) {
        mApi.getCompleteDetail(mSharedPref.getString(Constants.KEY_COOKIE,""),dataId,type,completeId)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void commitSuggest(Subscriber<ApiResult> subscriber,String content,String imageUrl,String contact) {
        mApi.commitSuggest(mSharedPref.getString(Constants.KEY_COOKIE,""),content,imageUrl,contact)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void setSceneHidden(Subscriber<ApiResult> subscriber,int sceneId,boolean isHidden) {
        mApi.setSceneHidden(mSharedPref.getString(Constants.KEY_COOKIE,""),sceneId,isHidden)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void setSceneSortIndex(Subscriber<ApiResult> subscriber,String ids) {
        mApi.setSceneSortIndex(mSharedPref.getString(Constants.KEY_COOKIE,""),ids)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getCatalogList(Subscriber<CatalogList> subscriber) {
        mApi.getCatalogList(mSharedPref.getString(Constants.KEY_COOKIE,""))
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getArticleList(Subscriber<ArticleList> subscriber,String catalogKey) {
        mApi.getArticleList(mSharedPref.getString(Constants.KEY_COOKIE,""),catalogKey)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getCompleteQuestion(Subscriber<CompleteQuestion> subscriber,int dataId,int type,int completeId) {
        mApi.getCompleteQuestion(mSharedPref.getString(Constants.KEY_COOKIE,""),dataId,type,completeId)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getCompleteResult(Subscriber<CompleteResult> subscriber,int id) {
        mApi.getCompleteResult(mSharedPref.getString(Constants.KEY_COOKIE,""),id)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void submitCompleteQuestion(Subscriber<ApiResult> subscriber,int id,int time,String answer) {
        mApi.submitCompleteQuestion(mSharedPref.getString(Constants.KEY_COOKIE,""),id,time,answer)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }



}
